/**
 * Created by 春旺 on 2017/3/22.
 */
//**********************************************************************************************
// ReverseNumber.java  Java Foundations
//
// Demonstrates use of a do loop.
//**********************************************************************************************
import java.util.Scanner;

public class ReverseNumber
{
    //-----------------------------------------------------------------------------------------
    // Reverse the digits of an integer mathematically.
    //------------------------------------------------------------------------------------------
    public static void main(String[] args)
    {
        int number, lastDigit, reverse = 0;

        Scanner scan = new Scanner(System.in);

        System.out.println("Enter a positive interger: ");
        number = scan.nextInt();

        do
        {
            lastDigit = number % 10;
            reverse = (reverse * 10) + lastDigit;
            number = number / 10;
        }
        while (number > 0);

        System.out.println("That number reversed is " +reverse);
    }
}
